package com.ruoyi.seedlingSys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.seedlingSys.domain.Caishou;
import com.ruoyi.seedlingSys.service.ICaishouService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采收管理Controller
 * 
 * @author ruoyi
 * @date 2025-03-11
 */
@RestController
@RequestMapping("/seedlingSys/caishou")
public class CaishouController extends BaseController
{
    @Autowired
    private ICaishouService caishouService;

    /**
     * 查询采收管理列表
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:caishou:list')")
    @GetMapping("/list")
    public TableDataInfo list(Caishou caishou)
    {
        startPage();
        List<Caishou> list = caishouService.selectCaishouList(caishou);
        return getDataTable(list);
    }

    /**
     * 导出采收管理列表
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:caishou:export')")
    @Log(title = "采收管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Caishou caishou)
    {
        List<Caishou> list = caishouService.selectCaishouList(caishou);
        ExcelUtil<Caishou> util = new ExcelUtil<Caishou>(Caishou.class);
        util.exportExcel(response, list, "采收管理数据");
    }

    /**
     * 获取采收管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:caishou:query')")
    @GetMapping(value = "/{caiShouID}")
    public AjaxResult getInfo(@PathVariable("caiShouID") Long caiShouID)
    {
        return success(caishouService.selectCaishouByCaiShouID(caiShouID));
    }

    /**
     * 新增采收管理
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:caishou:add')")
    @Log(title = "采收管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Caishou caishou)
    {
        return toAjax(caishouService.insertCaishou(caishou));
    }

    /**
     * 修改采收管理
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:caishou:edit')")
    @Log(title = "采收管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Caishou caishou)
    {
        return toAjax(caishouService.updateCaishou(caishou));
    }

    /**
     * 删除采收管理
     */
    @PreAuthorize("@ss.hasPermi('seedlingSys:caishou:remove')")
    @Log(title = "采收管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{caiShouIDs}")
    public AjaxResult remove(@PathVariable Long[] caiShouIDs)
    {
        return toAjax(caishouService.deleteCaishouByCaiShouIDs(caiShouIDs));
    }
}
